COUNT		EQU 30H
		ORG 00H
START:		MOV A,P3
		ANL A,#0FH
		MOV COUNT,A
		MOV P1,A
SK2:		JB P3.6,SK1
		LCALL DELY10MS
		JB P3.6,SK1
		INC COUNT
		MOV A,COUNT
		CJNE A,#16,NEXT
		MOV A,P3
		ANL A,#0FH
		MOV COUNT,A
NEXT:		MOV P1,A
WAIT:		JNB P3.6,WAIT
		LJMP SK2
SK1:		JB P3.7,SK2
		LCALL DELY10MS
		JB P3.7,SK2
		DEC COUNT
		MOV A,COUNT
		CJNE A,#0FFH,NEX
		MOV A,P3
		ANL A,#0FH
		MOV COUNT,A
NEX:		MOV P1,A
WAIT2:		JNB P3.7,WAIT2
		LJMP SK2
DELY10MS:	MOV R6,#20
		MOV R7,#248
D1:		DJNZ R7,$
		DJNZ R6,D1
		RET
		END
